package translinkApp.Adaptors.Sections;

import java.util.ArrayList;

import translinkApp.Activities.R;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

public class SectionedCheckBoxAdaptor extends SectionedAdapter {

	private Context mContext;

	public SectionedCheckBoxAdaptor(Context c) {
		mContext = c;
	}

	@Override
	protected View getHeaderView(String caption, int index, View convertView, ViewGroup parent) {

		TextView result = (TextView) convertView;

		if (convertView == null) {
			result = (TextView) ((Activity) mContext).getLayoutInflater().inflate(
					R.layout.sectionedcheckboxheader, null);
		}

		result.setText(caption);

		return (result);

	}

	public ArrayList<CheckBox> GetAllItems() {

		ArrayList<CheckBox> items = new ArrayList<CheckBox>();

		for (Section section : this.getSections()) {
			for (CheckBox box : section.adapter.checkBoxes) {
				items.add(box);
			}
		}

		return items;
	}
}